﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition;
using Microsoft.Practices.Prism.ViewModel;
using Microsoft.Practices.Prism.Events;
using System.Collections.ObjectModel;
using QLab.Events;

namespace QLab.Controllers
{
	[Export]
	[PartCreationPolicy(CreationPolicy.Shared)]
	public class CommandHistoryController : NotificationObject
	{
		private IEventAggregator _eventAggregator;

		private ObservableCollection<string> _commands;

		[ImportingConstructor]
		public CommandHistoryController(IEventAggregator EventAggregator)
		{
			_eventAggregator = EventAggregator;

			_eventAggregator.GetEvent<BeforeCommandExecuting>().Subscribe(OnBeforeCommandExecute, ThreadOption.UIThread);

			_commands = new ObservableCollection<string>();
		}

		#region Properties

		public ObservableCollection<string> Commands { get { return _commands; } }

		#endregion

		#region Callbacks

		public void OnBeforeCommandExecute(string Command)
		{
			_commands.Add(Command);
		}

		#endregion
	}
}
